//
//  PaymentListInfoViewController.m
//  HuLaQuan
//
//  Created by liyan on 16/1/18.
//  Copyright © 2016年 yuwubao. All rights reserved.
//

#import "PaymentListInfoViewController.h"

#import "GetTradeDetailEngine.h"

@interface PaymentListInfoViewController ()

@property (weak, nonatomic) IBOutlet UILabel *feeLabel;
@property (weak, nonatomic) IBOutlet UILabel *productLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *accountTypeLabel;
@property (weak, nonatomic) IBOutlet UILabel *orderNoLabel;

@property(nonatomic,strong)GetTradeDetailEngine *detailEngine;

@end

@implementation PaymentListInfoViewController

- (GetTradeDetailEngine *)detailEngine
{
    if (!_detailEngine) {
        _detailEngine = [[GetTradeDetailEngine alloc] init];
    }
    return _detailEngine;
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    
     [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getTradeDetailFinish:) name:@"GetTradeDetailFinish" object:nil];
    [YuNetworkStatusUtilities showProgressMessage:NETWORK_LOADING];
    [self.detailEngine getTradeDetail:self.tradeID];
}
- (void)viewWillDisappear:(BOOL)animated
{
     [[NSNotificationCenter defaultCenter] removeObserver:self name:@"GetTradeDetailFinish" object:nil];
    [super viewWillDisappear:YES];
    
}


- (void)getTradeDetailFinish:(NSNotification*) notification
{
    //
    //   dispatch_async(dispatch_get_main_queue(), ^{
    [YuNetworkStatusUtilities dismissHUD];
    NSDictionary *messageDic = [notification object];//获取到传递的对象
    if ([messageDic[@"isSuccess"] boolValue]) {
        NSDictionary *dic = messageDic[@"result"];
        
        self.feeLabel.text = [NSString stringWithFormat:@"¥%@",ServerMoneyFloatToShow(dic[@"3-交易金额"])];
        self.productLabel.text = dic[@"4-商品信息"];
        
        NSString *cardID = dic[@"6-交易方式"];
        
        self.accountTypeLabel.text = [NSString stringWithFormat:@"%@ (%@)",dic[@"7-银行名称"],[cardID substringFromIndex:cardID.length-4]];
        self.timeLabel.text = dic[@"8-交易时间"];
        self.orderNoLabel.text = self.tradeID;
    }else{
        [self showNetWorkError:messageDic[@"message"]];
        
        
    }
    //  });
    
}
-(void)setupUI
{
    self.title = @"账单详情";
    
    [self setupNavBackButton];
    
//    [KVNProgress showWithStatus:NETWORK_LOADING];
//    
    //[self.detailEngine getTradeDetail:@""];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
